track_recompute: don't recompute speed if we already have it.
authorrobertl <robertl>
Tue, 21 Jul 2009 05:18:37 +0000 (05:18 +0000)
committerrobertl <robertl>
Tue, 21 Jul 2009 05:18:37 +0000 (05:18 +0000)
route.c

diff --git a/route.c b/route.c
index 255129ad7a1df93da32bbdfee47f925de8f3381f..e6f8b1ff68b24a7cfada6d2a44436e3babf9bc60 100644 (file)
--- a/route.c
+++ b/route.c
@@ -565,10 +565,15 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
                }
 
                /*
-                * If we've moved as much as a meter, recompute speed.
+                * If we've moved as much as a meter, 
+                * conditionally recompute speeds.
                 */
                if (timed && (dist > 1)) {
-                       WAYPT_SET(this, speed, dist / labs(timed));
+                       if(!WAYPT_HAS(this, speed)) {
+                               // Only recompute speed if the waypoint
+                               // didn't already have a speed
+                               WAYPT_SET(this, speed, dist / labs(timed));
+                       }
                        if (this->speed > tdata->max_spd) {
                                tdata->max_spd = this->speed;
                        }